export function reportWebVitals() {
  if ('performance' in window) {
    const perf = window.performance

    // 页面加载性能
    window.addEventListener('load', () => {
      const timing = perf.timing
      const pageLoadTime = timing.loadEventEnd - timing.navigationStart
      console.log('Page Load Time:', pageLoadTime)

      // 发送性能数据到分析服务
      // TODO: 实现数据上报
    })

    // 资源加载性能
    const resources = perf.getEntriesByType('resource')
    resources.forEach(resource => {
      const { name, duration, initiatorType } = resource
      if (duration > 1000) {
        console.warn('Slow Resource:', name, initiatorType, duration)
      }
    })
  }
}

// 监控 JS 错误
window.addEventListener('error', (event) => {
  console.error('JS Error:', {
    message: event.message,
    filename: event.filename,
    lineno: event.lineno,
    colno: event.colno
  })
  // TODO: 实现错误上报
})

// 监控未处理的 Promise 错误
window.addEventListener('unhandledrejection', (event) => {
  console.error('Unhandled Promise Rejection:', event.reason)
  // TODO: 实现错��上报
}) 